// JavaScript Document
var register = {
    reg: function (phone,password,repassword,tcode) {
        var data = { phone: phone, password: password, repassword: repassword, tcode: tcode };
        $.commonAjax({
            url: 'B008',
            type: 'POST',
            data: data,
            isShowError: true,
            success: function (res) {
                $.alert(res.msg);
				if(res.code == 200){
					$.ls('bp_token', res.data.token);
					$.ls('bp_memberCode', res.data.member.code);
					$.ls('bp_checkcode', res.data.member.id);
					bp.jump('my.html');	
				}
            }, error: function (res) {
                $.layermsg(res.msg);
            }
        });
    }, sms: function (phone) {
        var data = { phone: phone, type: 2 };
        $.commonAjax({
            url: 'B014',
            type: 'GET',
            data: data,
            isShowError: true,
            success: function (res) {
                $.alert(res.msg);
            }, error: function (res) {
                $.layermsg(res.msg);
            }
        });
    }
}
$(function () {
    $('.backArrow').click(function () {
        bp.goback();
    });
    //register.reg();
    $('.v-code').click(function () {
		var phone = $('.userPhone').val();
        register.sms(phone);
    });
	$('.sub').click(function(){
		var phone = $('.userPhone').val(),
		tcode = $('.userCode').val(),
		password = $('.userPassword').val(),
		repassword = $('.againPassword').val();
		
		register.reg(phone,password,repassword,tcode);
		//$('.backArrow').click();
	});
})